﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;
using XCode;
using XCode.Configuration;
using XCode.DataAccessLayer;

namespace BingZi.HY.Core
{
    /// <summary>商品订单</summary>
    [Serializable]
    [DataObject]
    [Description("商品订单")]
    [BindIndex("PK_app_Order", true, "ID")]
    [BindTable("app_Order", Description = "商品订单", ConnName = "Center")]
    public partial class app_Order<TEntity> : Iapp_Order
    {
        #region 属性
        private Int32 _ID = 0;
        /// <summary>订单编号</summary>
        [DisplayName("订单编号")]
        [Description("订单编号")]
        [DataObjectField(true, true, false, 10)]
        [BindColumn(1, "ID", "订单编号", null, "int", 10, 0, false)]
        public virtual Int32 ID
        {
            get { return _ID; }
            set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } }
        }

        private Int32 _ProductID = 0;
        /// <summary>商品编号</summary>
        [DisplayName("商品编号")]
        [Description("商品编号")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(2, "ProductID", "商品编号", null, "int", 10, 0, false)]
        public virtual Int32 ProductID
        {
            get { return _ProductID; }
            set { if (OnPropertyChanging("ProductID", value)) { _ProductID = value; OnPropertyChanged("ProductID"); } }
        }

        private String _Phone =String.Empty;
        /// <summary>电话</summary>
        [DisplayName("电话")]
        [Description("电话")]
        [DataObjectField(false, false, false, 50)]
        [BindColumn(3, "Phone", "电话", null, "nvarchar(50)", 0, 0, true)]
        public virtual String Phone
        {
            get { return _Phone; }
            set { if (OnPropertyChanging("Phone", value)) { _Phone = value; OnPropertyChanged("Phone"); } }
        }

        private Int32 _Area = 0;
        /// <summary>地区</summary>
        [DisplayName("地区")]
        [Description("地区")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(4, "Area", "地区", null, "int", 10, 0, false)]
        public virtual Int32 Area
        {
            get { return _Area; }
            set { if (OnPropertyChanging("Area", value)) { _Area = value; OnPropertyChanged("Area"); } }
        }

        private String _Address = String.Empty;
        /// <summary>邮寄地址</summary>
        [DisplayName("邮寄地址")]
        [Description("邮寄地址")]
        [DataObjectField(false, false, false, 512)]
        [BindColumn(5, "Address", "邮寄地址", null, "nvarchar(512)", 0, 0, true)]
        public virtual String Address
        {
            get { return _Address; }
            set { if (OnPropertyChanging("Address", value)) { _Address = value; OnPropertyChanged("Address"); } }
        }

        private String _ZipCode = String.Empty;
        /// <summary>邮编</summary>
        [DisplayName("邮编")]
        [Description("邮编")]
        [DataObjectField(false, false, false, 20)]
        [BindColumn(6, "ZipCode", "邮编", null, "nvarchar(20)", 0, 0, true)]
        public virtual String ZipCode
        {
            get { return _ZipCode; }
            set { if (OnPropertyChanging("ZipCode", value)) { _ZipCode = value; OnPropertyChanged("ZipCode"); } }
        }

        private String _Email = String.Empty;
        /// <summary>联系邮箱</summary>
        [DisplayName("联系邮箱")]
        [Description("联系邮箱")]
        [DataObjectField(false, false, false, 100)]
        [BindColumn(7, "Email", "联系邮箱", null, "nvarchar(100)", 0, 0, true)]
        public virtual String Email
        {
            get { return _Email; }
            set { if (OnPropertyChanging("Email", value)) { _Email = value; OnPropertyChanged("Email"); } }
        }

        private String _Express=String.Empty;
        /// <summary>快递名</summary>
        [DisplayName("快递名")]
        [Description("快递名")]
        [DataObjectField(false, false, true, 50)]
        [BindColumn(8, "Express", "快递名", null, "nvarchar(50)", 0, 0, true)]
        public virtual String Express
        {
            get { return _Express; }
            set { if (OnPropertyChanging("Express", value)) { _Express = value; OnPropertyChanged("Express"); } }
        }

        private String _ExpressNumber=String.Empty;
        /// <summary>快递单号</summary>
        [DisplayName("快递单号")]
        [Description("快递单号")]
        [DataObjectField(false, false, true, 50)]
        [BindColumn(9, "ExpressNumber", "快递单号", null, "nvarchar(50)", 0, 0, true)]
        public virtual String ExpressNumber
        {
            get { return _ExpressNumber; }
            set { if (OnPropertyChanging("ExpressNumber", value)) { _ExpressNumber = value; OnPropertyChanged("ExpressNumber"); } }
        }

        private String _Addressee = String.Empty;
        /// <summary>收件人</summary>
        [DisplayName("收件人")]
        [Description("收件人")]
        [DataObjectField(false, false, false, 50)]
        [BindColumn(10, "Addressee", "收件人", null, "nvarchar(50)", 10, 0, false)]
        public virtual String Addressee
        {
            get { return _Addressee; }
            set { if (OnPropertyChanging("Addressee", value)) { _Addressee = value; OnPropertyChanged("Addressee"); } }
        }


        private String _Remark = String.Empty;
        /// <summary>订单备注</summary>
        [DisplayName("订单备注")]
        [Description("订单备注")]
        [DataObjectField(false, false, false, 512)]
        [BindColumn(11, "Remark", "订单备注", null, "nvarchar(512)", 10, 0, false)]
        public virtual String Remark
        {
            get { return _Remark; }
            set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } }
        }

        private Int32 _BuyCount = 1;
        /// <summary>购买数量</summary>
        [DisplayName("购买数量")]
        [Description("购买数量")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(12, "BuyCount", "购买数量", null, "int", 10, 0, false)]
        public virtual Int32 BuyCount
        {
            get { return _BuyCount; }
            set { if (OnPropertyChanging("BuyCount", value)) { _BuyCount = value; OnPropertyChanged("BuyCount"); } }
        }

 

        private Int32 _BuyUserID = 0;
        /// <summary>购买人</summary>
        [DisplayName("购买人")]
        [Description("购买人")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(13, "BuyUserID", "购买人", null, "int", 10, 0, false)]
        public virtual Int32 BuyUserID
        {
            get { return _BuyUserID; }
            set { if (OnPropertyChanging("BuyUserID", value)) { _BuyUserID = value; OnPropertyChanged("BuyUserID"); } }
        }

        private DateTime _BuyTime = DateTime.Now;
        /// <summary>购买时间</summary>
        [DisplayName("购买时间")]
        [Description("购买时间")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(14, "BuyTime", "购买时间", null, "datetime", 3, 0, false)]
        public virtual DateTime BuyTime
        {
            get { return _BuyTime; }
            set { if (OnPropertyChanging("BuyTime", value)) { _BuyTime = value; OnPropertyChanged("BuyTime"); } }
        }

        private String _BuyIP=String.Empty;
        /// <summary>购买IP</summary>
        [DisplayName("购买IP")]
        [Description("购买IP")]
        [DataObjectField(false, false, false, 50)]
        [BindColumn(15, "BuyIP", "购买IP", null, "nvarchar(50)", 0, 0, true)]
        public virtual String BuyIP
        {
            get { return _BuyIP; }
            set { if (OnPropertyChanging("BuyIP", value)) { _BuyIP = value; OnPropertyChanged("BuyIP"); } }
        }

        private Int32 _Status = (Int32)EnumOrderStatus.Unaudited;
        /// <summary>状态(未审核,已审核,已发货,已完成)</summary>
        [DisplayName("状态(未审核,已审核,已发货,已完成)")]
        [Description("状态(未审核,已审核,已发货,已完成)")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(16, "Status", "状态(未审核,已审核,已发货,已完成)", null, "tinyint", 3, 0, false)]
        public virtual Int32 Status
        {
            get { return _Status; }
            set { if (OnPropertyChanging("Status", value)) { _Status = value; OnPropertyChanged("Status"); } }
        }

        private DateTime _LastTime = DateTime.Now;
        /// <summary>最后更新时间</summary>
        [DisplayName("最后更新时间")]
        [Description("最后更新时间")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(17, "LastTime", "最后更新时间", null, "datetime", 3, 0, false)]
        public virtual DateTime LastTime
        {
            get { return _LastTime; }
            set { if (OnPropertyChanging("LastTime", value)) { _LastTime = value; OnPropertyChanged("LastTime"); } }
        }

        private Int32 _LastUser = 0;
        /// <summary>最后更新用户</summary>
        [DisplayName("最后更新用户")]
        [Description("最后更新用户")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(18, "LastUser", "最后更新用户", null, "int", 10, 0, false)]
        public virtual Int32 LastUser
        {
            get { return _LastUser; }
            set { if (OnPropertyChanging("LastUser", value)) { _LastUser = value; OnPropertyChanged("LastUser"); } }
        }

        private String _LastIP=String.Empty;
        /// <summary>最后更新IP</summary>
        [DisplayName("最后更新IP")]
        [Description("最后更新IP")]
        [DataObjectField(false, false, false, 50)]
        [BindColumn(19, "LastIP", "最后更新IP", null, "nvarchar(50)", 0, 0, true)]
        public virtual String LastIP
        {
            get { return _LastIP; }
            set { if (OnPropertyChanging("LastIP", value)) { _LastIP = value; OnPropertyChanged("LastIP"); } }
        }
		#endregion

        #region 获取/设置 字段值
        /// <summary>
        /// 获取/设置 字段值。
        /// 一个索引，基类使用反射实现。
        /// 派生实体类可重写该索引，以避免反射带来的性能损耗
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        public override Object this[String name]
        {
            get
            {
                switch (name)
                {
                    case "ID" : return _ID;
                    case "ProductID" : return _ProductID;
                    case "Phone" : return _Phone;
                    case "Area" : return _Area;
                    case "Address" : return _Address;
                    case "ZipCode" : return _ZipCode;
                    case "Email" : return _Email;
                    case "Express" : return _Express;
                    case "ExpressNumber" : return _ExpressNumber;
                    case "Addressee": return _Addressee;
                    case "Remark": return _Remark;
                    case "BuyCount" : return _BuyCount;
                    case "BuyUserID" : return _BuyUserID;
                    case "BuyTime" : return _BuyTime;
                    case "BuyIP" : return _BuyIP;
                    case "Status" : return _Status;
                    case "LastTime" : return _LastTime;
                    case "LastUser" : return _LastUser;
                    case "LastIP" : return _LastIP;
                    default: return base[name];
                }
            }
            set
            {
                switch (name)
                {
                    case "ID" : _ID = Convert.ToInt32(value); break;
                    case "ProductID" : _ProductID = Convert.ToInt32(value); break;
                    case "Phone" : _Phone = Convert.ToString(value); break;
                    case "Area" : _Area = Convert.ToInt32(value); break;
                    case "Address" : _Address = Convert.ToString(value); break;
                    case "ZipCode" : _ZipCode = Convert.ToString(value); break;
                    case "Email" : _Email = Convert.ToString(value); break;
                    case "Express" : _Express = Convert.ToString(value); break;
                    case "ExpressNumber" : _ExpressNumber = Convert.ToString(value); break;
                    case "Addressee": _Addressee = Convert.ToString(value); break;
                    case "Remark": _Remark = Convert.ToString(value); break;
                    case "BuyCount" : _BuyCount = Convert.ToInt32(value); break;
                    case "BuyUserID" : _BuyUserID = Convert.ToInt32(value); break;
                    case "BuyTime" : _BuyTime = Convert.ToDateTime(value); break;
                    case "BuyIP" : _BuyIP = Convert.ToString(value); break;
                    case "Status" : _Status = Convert.ToInt32(value); break;
                    case "LastTime" : _LastTime = Convert.ToDateTime(value); break;
                    case "LastUser" : _LastUser = Convert.ToInt32(value); break;
                    case "LastIP" : _LastIP = Convert.ToString(value); break;
                    default: base[name] = value; break;
                }
            }
        }
        #endregion

        #region 字段名
        /// <summary>取得商品订单字段信息的快捷方式</summary>
        public class _
        {
            ///<summary>订单编号</summary>
            public static readonly FieldItem ID = FindByName("ID");

            ///<summary>商品编号</summary>
            public static readonly FieldItem ProductID = FindByName("ProductID");

            ///<summary>电话</summary>
            public static readonly FieldItem Phone = FindByName("Phone");

            ///<summary>地区</summary>
            public static readonly FieldItem Area = FindByName("Area");

            ///<summary>邮寄地址</summary>
            public static readonly FieldItem Address = FindByName("Address");

            ///<summary>邮编</summary>
            public static readonly FieldItem ZipCode = FindByName("ZipCode");

            ///<summary>联系邮箱</summary>
            public static readonly FieldItem Email = FindByName("Email");

            ///<summary>快递名</summary>
            public static readonly FieldItem Express = FindByName("Express");

            ///<summary>快递单号</summary>
            public static readonly FieldItem ExpressNumber = FindByName("ExpressNumber");

            ///<summary>收件人</summary>
            public static readonly FieldItem Addressee = FindByName("Addressee");

            ///<summary>订单备注</summary>
            public static readonly FieldItem Remark = FindByName("Remark");

            ///<summary>购买数量</summary>
            public static readonly FieldItem BuyCount = FindByName("BuyCount");

            ///<summary>购买人</summary>
            public static readonly FieldItem BuyUserID = FindByName("BuyUserID");

            ///<summary>购买时间</summary>
            public static readonly FieldItem BuyTime = FindByName("BuyTime");

            ///<summary>购买IP</summary>
            public static readonly FieldItem BuyIP = FindByName("BuyIP");

            ///<summary>状态(未审核,已审核,已发货,已完成)</summary>
            public static readonly FieldItem Status = FindByName("Status");

            ///<summary>最后更新时间</summary>
            public static readonly FieldItem LastTime = FindByName("LastTime");

            ///<summary>最后更新用户</summary>
            public static readonly FieldItem LastUser = FindByName("LastUser");

            ///<summary>最后更新IP</summary>
            public static readonly FieldItem LastIP = FindByName("LastIP");

            static FieldItem FindByName(String name) { return Meta.Table.FindByName(name); }
        }
        #endregion
    }

    /// <summary>商品订单接口</summary>
    public partial interface Iapp_Order
    {
        #region 属性
        /// <summary>订单编号</summary>
        Int32 ID { get; set; }

        /// <summary>商品编号</summary>
        Int32 ProductID { get; set; }

        /// <summary>电话</summary>
        String Phone { get; set; }

        /// <summary>地区</summary>
        Int32 Area { get; set; }

        /// <summary>邮寄地址</summary>
        String Address { get; set; }

        /// <summary>邮编</summary>
        String ZipCode { get; set; }

        /// <summary>联系邮箱</summary>
        String Email { get; set; }

        /// <summary>快递名</summary>
        String Express { get; set; }

        /// <summary>快递单号</summary>
        String ExpressNumber { get; set; }

        /// <summary> 收件人</summary>
        String Addressee { get; set; }

        /// <summary> 订单备注</summary>
        String Remark { get; set; }

        /// <summary>购买数量</summary>
        Int32 BuyCount { get; set; }

        /// <summary>购买人</summary>
        Int32 BuyUserID { get; set; }

        /// <summary>购买时间</summary>
        DateTime BuyTime { get; set; }

        /// <summary>购买IP</summary>
        String BuyIP { get; set; }

        /// <summary>状态(未审核,已审核,已发货,已完成)</summary>
        Int32 Status { get; set; }

        /// <summary>最后更新时间</summary>
        DateTime LastTime { get; set; }

        /// <summary>最后更新用户</summary>
        Int32 LastUser { get; set; }

        /// <summary>最后更新IP</summary>
        String LastIP { get; set; }
        #endregion

        #region 获取/设置 字段值
        /// <summary>
        /// 获取/设置 字段值。
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        Object this[String name] { get; set; }
        #endregion
    }
}